﻿@page "/equipcontrol"
@using BootstrapBlazor.Components
@using TrackSystem.UI.Server.Units
@using TrackSystem.UI.Server.Units.UserAlarm


<div class="row g-3">
    @if (_selectedPart?.IsExist ?? false)
    {
        <div class="col-6 col-sm-4 col-md-3 col-lg-auto">
            <Button class="apple-btn"  OnClick="BtnBack" Color="Color.Info">返回</Button>
        </div>
    }
    else
    {
        <div class="col-6 col-sm-4 col-md-3 col-lg-auto">
            <Button class="apple-btn" OnClick="@BtnInitAll" Color="Color.Primary">全部载入</Button>
        </div>
        <div class="col-6 col-sm-4 col-md-3 col-lg-auto">
            <Button class="apple-btn" OnClick="@BtnUninitAll" Color="Color.Info">全部卸载</Button>
        </div>
        <div class="col-6 col-sm-4 col-md-3 col-lg-auto">
            <Button class="apple-btn" OnClick="BtnInitEquips" Color="Color.Success">载入装备</Button>
        </div>
        <div class="col-6 col-sm-4 col-md-3 col-lg-auto">
            <Button class="apple-btn" OnClick="BtnUnloadEquips" Color="Color.Info">卸载装备</Button>
        </div>
    }
</div>

@if (_equipItems is not null && !(_selectedPart?.IsExist ?? false))
{
    <Divider/>
    <div class="row">
        @foreach (var item in _equipItems)
        {
            <div class="col-6 col-sm-6 col-md-6 col-lg-6">
                <EquipView equip="item" hub="_hubIo" partSelect="_selectedPart"></EquipView>
            </div>
        }
    </div>
}

@* ------------------- 显示部件运行详情 -------------------- *@
@if (_selectedPart is not null)
{
    if (_selectedPart.Sensor is not null)
    {
        <Divider> 传感器  @_selectedPart.CurrentName </Divider>
        <SensorView snr="_selectedPart.Sensor" hub="_hubIo"></SensorView>
    }

    if (_selectedPart.Logic is not null)
    {
        <Divider> 逻辑程序  @_selectedPart.CurrentName </Divider>
        <LogicView logic="_selectedPart.Logic" hub="_hubIo"></LogicView>
    }

    if (_selectedPart.Loop is not null)
    {
        <Divider> 调节回路  @_selectedPart.CurrentName </Divider>
        <LoopView loop="_selectedPart.Loop" hub="_hubIo"></LoopView>
    }
}
else
{
    <AlarmControl AlarmMsg="_alarmMsg" AlarmNums="_numAlarm" hub="_hubIo"></AlarmControl>    
}



<Divider/>
<p class="text=algin:center">@_message</p>

